<!DOCTYPE html>
<html>
<head>
<title>Quantum Potential V(x)</title>
<style>
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
  }
  canvas {
    background-color: #ffffff;
    border: 1px solid #ccc;
  }
</style>
</head>
<body>
<canvas id="quantumPotentialCanvas" width="500" height="350"></canvas>
<script>
const canvas = document.getElementById('quantumPotentialCanvas');
const ctx = canvas.getContext('2d');

// Style settings
ctx.strokeStyle = 'black';
ctx.fillStyle = 'black';
ctx.lineWidth = 2;
ctx.font = '20px serif';
ctx.textAlign = 'center';

// Canvas coordinates
const canvasWidth = canvas.width;
const canvasHeight = canvas.height;

// Physics coordinates mapping
const originX = 220;
const originY = 250;
const a_dist = 120; // pixels for distance 'a'
const spikeHeight = 180;
const wallHeight = 220;

// Draw x-axis
ctx.beginPath();
ctx.moveTo(30, originY);
ctx.lineTo(canvasWidth - 30, originY);
ctx.stroke();

// Draw arrowhead for x-axis
const arrowHeadSize = 10;
ctx.beginPath();
ctx.moveTo(canvasWidth - 30, originY);
ctx.lineTo(canvasWidth - 30 - arrowHeadSize, originY - arrowHeadSize / 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(canvasWidth - 30, originY);
ctx.lineTo(canvasWidth - 30 - arrowHeadSize, originY + arrowHeadSize / 2);
ctx.stroke();

// Draw infinite potential wall at x = -a
const x_neg_a = originX - a_dist;
ctx.beginPath();
ctx.moveTo(x_neg_a, originY);
ctx.lineTo(x_neg_a, originY - wallHeight);
ctx.stroke();

// Draw delta function potential at x = 0
// It is drawn as a filled shape.
const spikeBaseWidth = 16;
ctx.beginPath();
ctx.moveTo(originX - spikeBaseWidth / 2, originY);
ctx.lineTo(originX, originY - spikeHeight);
ctx.lineTo(originX + spikeBaseWidth / 2, originY);
ctx.closePath();
ctx.fill();

// White line inside the spike to mimic the original art style where the axis seems to be "inside"
ctx.strokeStyle = 'white';
ctx.lineWidth = 1.5;
ctx.beginPath();
ctx.moveTo(originX, originY - 5);
ctx.lineTo(originX, originY - spikeHeight * 0.9);
ctx.stroke();

// Reset stroke style
ctx.strokeStyle = 'black';
ctx.lineWidth = 2;

// Draw the V(x) axis line extending above the spike
ctx.beginPath();
ctx.moveTo(originX, originY - spikeHeight);
ctx.lineTo(originX, originY - spikeHeight - 20);
ctx.stroke();

// Add labels
ctx.fillStyle = 'black';

// Labels on axes
ctx.textBaseline = 'top';
ctx.fillText('0', originX, originY + 8);
ctx.fillText('-a', x_neg_a, originY + 8);
ctx.textBaseline = 'middle';
ctx.textAlign = 'left';
ctx.fillText('x', canvasWidth - 25, originY);

// Label for V(x)
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
ctx.fillText('V(x)', originX, originY - spikeHeight - 25);

// Labels for regions
ctx.font = 'bold 24px serif';
ctx.fillText('I', originX - a_dist / 2, originY - 60);
ctx.fillText('II', originX + a_dist / 2 + 20, originY - 60);

// Figure caption
ctx.font = '20px serif';
ctx.textBaseline = 'bottom';
ctx.textAlign = 'center';
ctx.fillText('Fig. 1.19', canvasWidth / 2, canvasHeight - 5);

</script>
</body>
</html>